﻿using HoloJson.Mini;
using HoloJson.Mini.Builder;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;


namespace HoloJson.MiniDriver
{
    internal class BuilderDemoDriver
    {
        private LiteJsonBuilder jsonBuilder;

        internal BuilderDemoDriver()
        {
            jsonBuilder = new HoloJsonMiniBuilder();
        }

        internal async Task<string> RunTestBuild()
        {
            string jsonStr = null;
            try {

                // ????
                var jsonNode = new Dictionary<string, object>();
                jsonNode.Add("key1", 1001);
                jsonNode.Add("key2", "value 2");
                jsonNode.Add("key3", new DateTime());
                jsonNode.Add("key4", new List<int>() { 1, 2, 3 });
                // ....

                jsonStr = await jsonBuilder.BuildAsync(jsonNode);

                System.Diagnostics.Debug.WriteLine("Built: jsonStr = " + jsonStr);


            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine("Build failed.", ex);
            }

            return jsonStr;
        }

    }
}
